package com.hcinfos.gsoo.adapter;

import java.util.List;

import com.hcinfos.gsoo.R;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class MyOrderAdapter extends BaseAdapter {

	private List<String> list;
	private LayoutInflater lif;

	public MyOrderAdapter(Context context, List<String> list) {

		this.list = list;
		lif = LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		Holder holder;
		if (convertView == null) {
			holder = new Holder();
			convertView = lif
					.inflate(R.layout.adapter_my_order_list_item, null);
			holder.icon_iv = (ImageView) convertView.findViewById(R.id.icon_iv);
			holder.state_tv = (TextView) convertView
					.findViewById(R.id.state_tv);
			holder.submit_bt = (Button) convertView
					.findViewById(R.id.submit_bt);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();

		}

		if (position == 0) {
			holder.icon_iv.setImageResource(R.drawable.gsoo_order_advance_logo);
			holder.state_tv.setText("未付款");
			holder.submit_bt.setText("付款");
			holder.submit_bt.setTextColor(Color.WHITE);
			holder.submit_bt.setBackgroundResource(R.drawable.gsoo_button_guide_press);
		} else {

			holder.icon_iv
					.setImageResource(R.drawable.gsoo_order_advance_logo_lock);
			holder.state_tv.setText("已关闭");
			holder.submit_bt.setText("再订");
			holder.submit_bt.setTextColor(Color.parseColor("#5F656E"));
			holder.submit_bt.setBackgroundResource(R.drawable.gsoo_button_white_normal);
		}

		return convertView;
	}

	public final class Holder {

		TextView time_tv;
		TextView name_tv;
		ImageView icon_iv;
		TextView state_tv;
		Button submit_bt;

	}

	public void setDataChange(List<String> list) {
		this.list = list;
	}

}
